var __extends =
    (this && this.__extends) ||
    (function () {
      var t = function (i, e) {
        return (t =
          Object.setPrototypeOf ||
          ({ __proto__: [] } instanceof Array &&
            function (t, i) {
              t.__proto__ = i;
            }) ||
          function (t, i) {
            for (var e in i)
              Object.prototype.hasOwnProperty.call(i, e) && (t[e] = i[e]);
          })(i, e);
      };
      return function (i, e) {
        function a() {
          this.constructor = i;
        }
        if ("function" != typeof e && null !== e)
          throw new TypeError(
            "Class extends value " + String(e) + " is not a constructor or null"
          );
        t(i, e),
          (i.prototype =
            null === e
              ? Object.create(e)
              : ((a.prototype = e.prototype), new a()));
      };
    })(),
  VIPManagerView = (function (t) {
    function i() {
      var i = t.call(this) || this;
      return (
        (i.vipDataArr = []),
        (i.needLvValue = "0"),
        (i.onLoadLingQuVipData = {
          caller: i,
          code: 6153,
          method: function (t) {
            if ((ToastView.toastView(t.msg), 0 == t.code))
              return (
                WebSocketService.send({ c: 6102, d: { lvl: i.current_vip } }),
                Laya.stage.event("GameMainView", "exp"),
                void Laya.stage.event("HomePageView", "exp")
              );
          },
        }),
        i.btn_vip_cancle.on(Laya.Event.CLICK, i, i.onClose),
        i.btn_vip_shengji.on(Laya.Event.CLICK, i, i.onVIPShengJiActionFn),
        WebSocketService.addListener({
          caller: i,
          code: 6102,
          method: i.onLoadVipLevelData,
        }),
        WebSocketService.addListener(i.onLoadLingQuVipData),
        i.btn_vip_left.on(Laya.Event.CLICK, i, i.onTabVipDidClick),
        i.btn_vip_middle.on(Laya.Event.CLICK, i, i.onTabVipDidClick),
        i.btn_vip_right.on(Laya.Event.CLICK, i, i.onTabVipDidClick),
        (i.list_vip_content.selectEnable = !0),
        (i.list_vip_content.vScrollBarSkin = ""),
        i.list_vip_content.on(Laya.Event.CLICK, i, i.onVipDengJiDidClickFn),
        (i.list_vip_content.renderHandler = new Laya.Handler(
          i,
          i.updateViPDengJiItem
        )),
        Laya.stage.on("VIPManagerView", i, i.eventHandler),
        i
      );
    }
    return (
      __extends(i, t),
      (i.openView = function () {
        return (
          null == this.vipManagerVC && (this.vipManagerVC = new i()),
          (this.vipManagerVC.current_vip = 0),
          (this.vipManagerVC.VIPMaxValue = 1),
          (this.vipManagerVC.default_vip = -2),
          (this.vipManagerVC.current_Index = this.vipManagerVC.default_vip),
          WebSocketService.send({ c: 6102, d: { lvl: -2 } }),
          (this.vipManagerVC.list_vip_content.visible = !1),
          this.vipManagerVC.btn_vip_left.selected,
          this.vipManagerVC.btn_vip_middle.selected,
          this.vipManagerVC.btn_vip_right.selected,
          (this.vipManagerVC.btn_vip_left.label = "VIP 0"),
          (this.vipManagerVC.btn_vip_middle.label = "VIP 1"),
          (this.vipManagerVC.btn_vip_right.label = "VIP 2"),
          this.vipManagerVC
        );
      }),
      (i.prototype.onLoadVipLevelData = function (t) {
        if (0 == t.code) {
          (this.vipDataArr = t.data.list),
            (this.VIPMaxValue = t.data.maxLvl),
            this.vipDataArr.length > 0 && (this.list_vip_content.visible = !0),
            -2 == this.default_vip &&
              (t.data.vipLvl < 0
                ? ((this.label_vipManager_title.text = "您当前是 非VIP"),
                  (this.btn_vip_left.visible = !1),
                  (this.btn_vip_middle.label = "VIP 0"),
                  (this.btn_vip_right.label = "VIP 1"),
                  (this.btn_vip_right.visible = !0),
                  (this.current_vip = 0))
                : 0 == t.data.vipLvl
                ? ((this.label_vipManager_title.text = "当前等级：VIP 0"),
                  (this.btn_vip_left.visible = !0),
                  (this.btn_vip_right.visible = !0),
                  (this.btn_vip_left.label = "VIP 0"),
                  (this.btn_vip_middle.label = "VIP 1"),
                  (this.btn_vip_right.label = "VIP 2"),
                  (this.current_vip = 1))
                : t.data.vipLvl == t.data.maxLvl
                ? ((this.btn_vip_left.visible = !0),
                  (this.btn_vip_left.label = "VIP " + (t.data.vipLvl - 1)),
                  (this.btn_vip_middle.label = "VIP " + t.data.vipLvl),
                  (this.btn_vip_right.visible = !1),
                  (this.current_vip = t.data.vipLvl),
                  (this.label_vipManager_title.text =
                    "当前等级：VIP " + t.data.vipLvl))
                : ((this.label_vipManager_title.text =
                    "当前等级：VIP " + t.data.vipLvl),
                  (this.btn_vip_left.label = "VIP " + (t.data.vipLvl - 1)),
                  (this.btn_vip_middle.label = "VIP " + t.data.vipLvl),
                  (this.btn_vip_right.label = "VIP " + (t.data.vipLvl + 1)),
                  (this.btn_vip_left.visible = !0),
                  (this.btn_vip_middle.visible = !0),
                  (this.btn_vip_right.visible = !0),
                  (this.current_vip = t.data.vipLvl))),
            this.current_vip > t.data.vipLvl
              ? ((this.label_vipshengji_msg.text =
                  "升级到VIP " +
                  this.current_vip +
                  "还需要 " +
                  t.data.next +
                  " 金"),
                (this.btn_vip_shengji.visible = !0),
                (this.needLvValue = t.data.next))
              : ((this.label_vipshengji_msg.text = ""),
                (this.needLvValue = "0"),
                (this.btn_vip_shengji.visible = !1)),
            (this.current_Index = this.current_vip),
            (this.label_hpBag_lefttime.text =
              "无" != t.data.hpBag ? "气血石剩余时间：" + t.data.hpBag : "");
          var i;
          this.dataSource = [];
          for (var e = 0; e < this.vipDataArr.length; e++)
            (i = {
              label_vip_title: { text: this.vipDataArr[e].title },
              label_vip_button: { label: "领取" },
            }),
              this.dataSource.push(i);
          this.list_vip_content.dataSource = this.dataSource;
        }
      }),
      (i.prototype.onVipDengJiDidClickFn = function (t) {
        if ("" != t.target.name && "label_vip_button" == t.target.name) {
          var i = this.vipDataArr[this.list_vip_content.selectedIndex].type,
            e = this.vipDataArr[this.list_vip_content.selectedIndex].choose,
            a = this.vipDataArr[this.list_vip_content.selectedIndex].id;
          "4" == i && "1" == e
            ? VipSelectWearDialog.showVipSelectWearDialog(a)
            : WebSocketService.send({
                c: 6153,
                d: { pid: a, t: i, lvl: this.current_vip },
              });
        }
      }),
      (i.prototype.updateViPDengJiItem = function (t, i) {
        var e = t.getChildByName("label_vip_seq"),
          a = t.getChildByName("label_vip_subtitle"),
          n = t.getChildByName("label_vip_button");
        "0" == this.vipDataArr[i].state
          ? ((n.skin = ""), (n.visible = !1), (a.visible = !1))
          : "1" == this.vipDataArr[i].state
          ? ((n.visible = !0),
            (n.skin = "comp/preload/btn_com_sure.png"),
            (a.visible = !1))
          : ((n.skin = ""),
            (n.visible = !1),
            (a.visible = !0),
            (a.text = "已领取")),
          0 == this.vipDataArr[i].type
            ? ((e.text = "特权"), (n.skin = ""), (n.visible = !1))
            : 1 == this.vipDataArr[i].type
            ? (e.text = "物品")
            : 2 == this.vipDataArr[i].type
            ? (e.text = "经验")
            : 3 == this.vipDataArr[i].type
            ? (e.text = "宝石")
            : 4 == this.vipDataArr[i].type && (e.text = "副将");
      }),
      (i.prototype.onTabVipDidClick = function (t) {
        if ("" != t.target.name) {
          this.default_vip = 0;
          var i,
            e = t.target.label.slice(3),
            a = parseInt(e);
          "item0" == t.target.name
            ? 0 == a
              ? ((i = 0), (this.btn_vip_left.visible = !1))
              : a >= 1 &&
                a <= this.VIPMaxValue &&
                ((i = a),
                (this.btn_vip_left.visible = !0),
                (this.btn_vip_right.visible = !0))
            : "item1" == t.target.name
            ? a >= 0 && a <= this.VIPMaxValue && (i = a)
            : "item2" == t.target.name &&
              (a >= 1 && a < this.VIPMaxValue
                ? ((i = a),
                  (this.btn_vip_left.visible = !0),
                  (this.btn_vip_right.visible = !0))
                : (a = this.VIPMaxValue) &&
                  ((i = a), (this.btn_vip_right.visible = !1))),
            (this.current_vip = a),
            WebSocketService.send({ c: 6102, d: { lvl: a } }),
            (this.btn_vip_left.label = "VIP " + (i - 1)),
            (this.btn_vip_middle.label = "VIP " + i),
            (this.btn_vip_right.label = "VIP " + (i + 1));
        }
      }),
      (i.prototype.dealShowTabBarButtonLabel = function (t) {
        0 == t
          ? (0, (this.btn_vip_left.visible = !1))
          : t >= 1 &&
            t <= this.VIPMaxValue &&
            (t,
            (this.btn_vip_left.visible = !0),
            (this.btn_vip_right.visible = !0));
      }),
      (i.prototype.onVIPShengJiActionFn = function () {
        CoinMoneyChangeDialog.showUseHunView(this.needLvValue);
      }),
      (i.prototype.onClose = function () {
        this.removeSelf();
      }),
      (i.prototype.eventHandler = function (t) {
        t &&
          "refreshVIP_NeedCoin" == t &&
          WebSocketService.send({ c: 6102, d: { lvl: this.current_vip } });
      }),
      i
    );
  })(ui.VIPManagerController.VIPManagerViewUI);
